<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="../../../common/taglib.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<sfa:mainTitle></sfa:mainTitle>
		<%@ include file="../../../common/meta.jsp"%> 
		<script type="text/javascript">
		$(function(){
			$("#btn_add").click(function(){
				
				var productList = $(".saleProduct:checked");
				if(productList.length==0){
					alert("请选择要添加的产品!");
					return false;
				} 
				var productName = ""; 
				var productId = ""; 
				var productCode = ""; 
				productList.each(function(i,o){
					productCode = $(o).val();
					productName =$(o).next().val();	
					productId =$(o).next().next().val();	
				}); 
				parent.addProducts(productName,productId,productCode);
			});
			
		});
		
		</script>
	</head>
	<body>
	
	<div class="webpart3 contentarea">
				<div class="webpart-head">
					<div class="webpart-head-item">
						产品关联
					</div>
				</div>
				<div class="webpart-main" id="maindiv">
					<div class="webpart-main-item" style="padding-top: 12px;">
					<div class="search">
				<form method="get">
					<table id="mytable" cellpadding="0" cellspacing="0"
							style="margin-top: 0px; text-align: center;">
						<tbody>
							<tr>
								<th>
									产品代码
								</th>
								<td>
									<input type="text" name="productCode" id="productCode"
										class="input-txt" value="${productCode}">
								</td>
								<th>
									产品名称
								</th>
								<td>
									<input type="text" name="productTitle" id="productTitle"
										class="input-txt" value="${productTitle}">
								</td> 
								<th>
									供应商:${productProvider}
									<input type="hidden" name="productProvider" id="productProvider"
										class="input-txt" value="${productProvider}">
								</th>
							</tr>
							 
							<tr>
								<td colspan="6" class="table_btn">
									<input type="submit" class="linkbtn2" value="查询" />
									&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
									<input type="button" class="linkbtn2" value="清空"
										onclick="location.href='${path}/productandtrain/product/index/salepro';" />
								</td>
							</tr>
						</tbody>
					</table>
				</form>
				<table id="mytable" cellpadding="0" cellspacing="0"
							class="dg_borderstyle  trStyleTable"
							style="margin-top: 0px; text-align: center; width: 100%">
					<tbody>
						<tr class="tabheader">
							<th>
								产品关联
							</th>
							<th>
								产品代码
							</th>
							<th>
								产品名称
							</th>
							<th>
								供应商
							</th> 
							<th>
								是否有附件
							</th>
						</tr>
						
						<c:forEach items="${pagination.resultList}" var="product">
						<tr id="tr_${product.PRODUCTID}" class="gray datarow">
						   <td>
							<input type="radio"  class="saleProduct" name="saleProduct"  value="${product.PRODUCTCODE}" />
							<input type="hidden" value="${product.PRODUCTNAME }"/>
							<input type="hidden" value="${product.productid}"/>
							</td>
							<td>
								<span>
								${product.PRODUCTCODE} 
							    </span>
							</td>
							<td>
								<span>${product.PRODUCTNAME}</span>
							</td> 
							<td>
								<span>${product.providername}</span>
							</td>
							<td>
							<span>
								<c:if test="${product.isaffix=='Y'}">是</c:if>
								<c:if test="${product.isaffix=='N'}">否</c:if>
							</span>
							</td>
						</tr>
						</c:forEach>
					</tbody>
				</table>
				<c:if test="${not empty pagination.multiPage}">
					<div class="dg_pagerstyle">
						<div class="pagebtn">
							${pagination.multiPage}
						</div>
					</div>
				</c:if>
				<input type="button" class="com_btn" id="btn_add" style="margin-left: 85%;margin-top: 8px;" value="添加到计划书" />
			</div>
		</div>
		</div>
		<div class="webpart-foot">
			<div class="webpart-foot-item">
			</div>
		</div>
		</div>
	</body>
</html>